package com.whenjun.enums;


import com.alibaba.fastjson.JSON;
import com.ifootbook.util.FootBookException;
import com.whenjun.dto.kq.KqDoorType;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
@AllArgsConstructor
public enum KqDoorTypeEnum {

    shangban("shangban", "上班考勤"),

    xiaban("xiaban", "下班考勤"),

    huwai("huwai", "户外工作考勤"),

    waichu("waichu", "外出考勤"),

    tongdao("tongdao", "楼梯通道"),

    canting("canting", "餐厅"),

    xiuxi("xiuxi", "休息区"),

    wc("wc", "卫生间"),

    ;

    private String code;

    private String name;

    public static void checkIn(String code) {
        Boolean isIn = false;
        for (KqDoorTypeEnum kqDoorType : KqDoorTypeEnum.values()) {
            if (kqDoorType.getCode().equals(code)) {
                isIn = true;
                break;
            }
        }
        if (isIn.equals(false)) {
            throw new FootBookException("groupCode错误");
        }
    }

    public static List<KqDoorType> toList() {
        List<KqDoorType> kqDoorTypes = new ArrayList<>();
        for (KqDoorTypeEnum kqDoorTypeEnum : KqDoorTypeEnum.values()) {
            KqDoorType kqDoorType = new KqDoorType();
            kqDoorType.setCode(kqDoorTypeEnum.getCode());
            kqDoorType.setName(kqDoorTypeEnum.getName());

            kqDoorTypes.add(kqDoorType);
        }
        return kqDoorTypes;
    }

    public static void main(String[] args) {
        System.out.println(JSON.toJSONString(KqDoorTypeEnum.toList()));
    }
}
